//农家乐管理 -- 农家乐详情
var starttime = ""; //开始时间
var endtime = ""; //结束时间
var pagesize = 10;
var pageindex = 1;
var sortfild = ""; //排序的关键字
var sortway = ""; //排序：升序、降序
var uid_department = getCookie("admin_role");
var uid_encryptid = getCookie("uid_encryptid");
var current_business_encryptId = getCookie("business_encryptId");
var current_farm_encryptId = getCookie("shop_encryptId");
var editIndex,layedit;
var ttname;
var palytypelist = ""; //游玩类型加密id
$(function() {

    //表格的文字说明
    $(document).on("mouseover",".show_tabletitel_tips",function(){
        if($(this).attr("text")!=""&&$(this).attr("text")!=null){
            layer.tips($(this).attr("text"), $(this), {
                tips: [1, '#3595CC'],
                time: 0
            })
        }
    });
    $(document).on("mouseout",".show_tabletitel_tips",function(){
        layer.closeAll('tips');
    });

	layui.use(['form', 'layer', 'layedit'], function() {
		$ = layui.jquery;
		layedit = layui.layedit;

		// //创建一个编辑器
		// editIndex = layedit.build('business_intr'); //id值
        //
		// //给文本框赋值
		// var str = "<p>小狐狸</p>"
		// layedit.setContent(editIndex, str)
	});

	/*基本信息修改*/
	$(".client_int").bind('input propertychange,select change', function() {
		$(".client_tool").css("display", "none");
		$(this).siblings(".client_tool").css("display", "inline-block");
	});
	$(".cancel").click(function() {
		$(this).parent(".client_tool").css("display", "none");
	});

	//悬浮显示 当宽度小于 文字宽度时，则鼠标移到该内容时，悬浮显示，将文字全部显示出来
	$(document).on("mouseover", ".show_tips", function() {
		if($(this).width() > $(this).parent().width()) {
			layer.tips($(this).html(), $(this), {
				tips: [1, '#3595CC'],
				time: 0
			})
		}
	});
	$(document).on("mouseout", ".show_tips", function() {
		layer.closeAll('tips');
	});

	//全选中或全不选
	$("#checkAll,#room_checkAll,#food_checkAll").click(function() {
		if($(this).is(':checked')) {
			$(".checkbox").prop("checked", true);
		} else {
			$(".checkbox").prop("checked", false);
		}
	})

    //获取商家基本信息
    getbusinessinfo();

	getData();

})

function getData() {
	
	/************基本信息***************/
	$("#basic_info").click(function(){
		$(".bottom_page").hide();
		//调用方法
		getbusinessinfo();
	});
	
	/************农家图集***************/
	$("#store_images").click(function(){
        $(".bottom_page").hide();
		//调用方法
        myatlasinfo();
	});
	
	/************住宿信息***************/
	$("#accom_info").click(function(){
		$(".bottom_page").show();
        ttname = "农家住宿信息";
		$("#first_button").click();
	});
	
	/************美食信息***************/
	$("#food_info").click(function(){
		$(".bottom_page").show();
        ttname = "农家美食信息";
		$("#first_button").click();
	});
	
	/************评论信息***************/
	$("#comm_info").click(function(){
		$(".bottom_page").show();
        ttname = "农家评论信息";
		$("#first_button").click();
	});
	
	/************收藏信息***************/
	$("#collect_info").click(function(){
		$(".bottom_page").show();
        ttname = "农家收藏信息";
		$("#first_button").click();
	});

    /************定制信息***************/
    $("#customize_info").click(function(){
        $(".bottom_page").show();
        ttname = "农家定制信息";
        $("#first_button").click();
    });
	
}

/*************************************---基本信息---******************************/
//获取商家基本信息
function getbusinessinfo() {
    var layLoad=layer.load(2);
    $.post('/farmbusinesinfo/getfarminfo', {
        "business_encryptId": current_business_encryptId,
        "farm_encryptId": current_farm_encryptId
    }, function (value) {
        layer.close(layLoad);
        if (value.status == 0 && value.msg == "ok") {
            var list = value.list;
            if(list.length>0){
                $("#client_name").text(list[0].tel+"商家详情");
                $("#fusername").text((list[0].business_name == null ?"":list[0].business_name));
                $("#cfarmtype").text((list[0].farmtypeName == null ?"":list[0].farmtypeName));
                $("#ctel").attr("value",(list[0].tel == null ?"":list[0].tel));
                $("#cbusinessLegal").text((list[0].business_Legal == null ?"":list[0].business_Legal));
                $("#CompanyName").text((list[0].CompanyName == null ?"":list[0].CompanyName));
                $("#cbusiness_create").text((list[0].business_create == null ?"":list[0].business_create));
                $("#clicense").attr("value",(list[0].business_license == null ?"":list[0].business_license));
                $("#Credit").text((list[0].business_Credit == null ?"":list[0].business_Credit));
                // $("#ccity").attr("value",(list[0].city+list[0].district));
                $("#ccity").attr("value",(list[0].city)); //城市
                $("#cdistrict").attr("value",(list[0].district)); //区县
                $("#cfarm_area").find("option[value='"+list[0].farm_area+"']").attr("selected",true);
                $("#cfarm_status").find("option[value='"+list[0].farm_status+"']").attr("selected",true);
                $("#cfarm_address_span").attr("value",(list[0].farm_address));
                $("#cViews").text((list[0].farm_views == null ?"":list[0].farm_views+"次"));
                $("#cscore").text((list[0].farm_score == null ?"":list[0].farm_score+"分"));
                $("#cfarm_dining").find("option[value='"+list[0].farm_dining+"']").attr("selected",true);
                $("#cfarm_scale").find("option[value='"+list[0].farm_scale+"']").attr("selected",true);
                $("#cfarm_consume").attr("value",(list[0].farm_consume));
                $("#cfarm_room").find("option[value='"+list[0].farm_room+"']").attr("selected",true);
                $("#ccreatetime").text((list[0].createtime == null ?"":list[0].createtime));
                $("#cfarm_bus_route").val((list[0].farm_bus_route == null ?"":list[0].farm_bus_route));
                $("#cfarm_self_route").val((list[0].farm_self_route == null ?"":list[0].farm_self_route));

                palytypelist = list[0].palyType_encryptId; //游玩类型

                layui.use(['form', 'layer', 'layedit'], function() {
                    $ = layui.jquery;
                    layedit = layui.layedit;

                    //创建一个编辑器
                    editIndex = layedit.build('business_intr'); //id值

                    //给文本框赋值
                    var str = "<p>"+list[0].farm_Intr_info+"</p>"
                    layedit.setContent(editIndex, str);
                });
            }

            //加载游玩类型
            getfarmPlayTypelist();

        } else {
            if (value.msg == null || value.msg == "") {
                layer.alert("接口出现错误！", {icon: 2})
            } else {
                layer.alert(value.msg, {icon: 2})
            }
        }
    })
}


//获取农家乐游玩类型
var allfarmPlaytypelist = new Array();
function getfarmPlayTypelist() {
    $(".farm_playtype").empty();
    $.post('/farmplaytype/getAllfarmPlaytype', {}, function (data) {
        if (data.status == 0 && data.msg == 'ok') {
            var list = data.list;
            allfarmPlaytypelist = data.list;
            var farmplayRemarks = palytypelist.split(",");
            var str = "";
            if(list.length>0){
                for (var i = 0; i < list.length; i++) {
                    if ($.inArray(list[i].encryptId, farmplayRemarks) != -1) {
                        str += "<li><a href=\"javascript:void(0)\" onclick='modifyRemarks(this)' name=\"" +list[i].farmId+ "\"  value=\"" +list[i].encryptId+ "\" class=\"xinjian_btn remarks_a\">" + list[i].title + "</a></li>";
                    } else {
                        str += "<li><a href=\"javascript:void(0)\" onclick='modifyRemarks(this)' name=\"" +list[i].farmId+ "\"  value=\"" +list[i].encryptId+ "\" class=\"xinjian_btn_white remarks_a\">" + list[i].title + "</a></li>";
                    }
                }
                $(".farm_playtype").html(str);
            }
        } else {
            if(data.msg==null||data.msg==""){
                layer.alert("接口出现错误！", {icon: 2})
            }else{
                layer.alert(data.msg, {icon: 2})
            }
        }
    })
}

//显示营业执照
function showVoucher(){
    var url = $("#clicense").attr("value");
    if(url!="" && url != undefined){
        var cancel = "<a onclick='mclose()' class=\"sure_btn1\">关闭</a>";
        prompt = "<img style='max-width: 80%;' src='"+url+"'>";
        var html = "<div class='linepopup1'>" + prompt + "</div>" + cancel;
        parent.ComOpenWin(1, "营业执照", "480px", 'auto', html, 1);
    }
}

//修改备注
function modifyRemarks(obj) {
    //取消
    if ($(obj).hasClass("xinjian_btn")) {
        $(obj).addClass("xinjian_btn_white").removeClass("xinjian_btn");
    }
    //添加
    else {
        $(obj).addClass("xinjian_btn").removeClass("xinjian_btn_white");
    }
    var farmplayRemarks = "",farmplay_encryptId="";
    //游玩类型备注加密id
    var mainRemarkslist = $(".farm_playtype").find(".xinjian_btn");
    for (var i = 0; i < mainRemarkslist.length; i++) {
        if (i == 0) {
            farmplay_encryptId += $(mainRemarkslist[i]).attr('value');
            farmplayRemarks += $(mainRemarkslist[i]).text();
        } else {
            farmplay_encryptId += "," + $(mainRemarkslist[i]).attr('value');
            farmplayRemarks += "," + $(mainRemarkslist[i]).text();
        }
    }

    //修改
    $.post('/farmbusinesinfo/modifyfarmplayRemarks', {
        "farm_encryptId":current_farm_encryptId,
        "farmplay_encryptId":farmplay_encryptId,
        'farmplaymark': farmplayRemarks
    }, function (value) {
        if (value.status == 0 && value.msg == 'ok') {

        } else {
            //取消
            if ($(obj).hasClass("xinjian_btn")) {
                $(obj).addClass("xinjian_btn_white").removeClass("xinjian_btn");
            } else {
                //添加
                $(obj).addClass("xinjian_btn").removeClass("xinjian_btn_white");
            }
            if (value.msg == null || value.msg == "") {
                layer.alert("接口出现错误！", {icon: 2})
            } else {
                layer.alert(value.msg, {icon: 2})
            }
        }
    })

}



//更改商家基本信息
function updateinfo(updatefiled,updateid,type) {
    var updateval = "";
    if(type == 1){
        //文本框
        updateval = $("#"+updateid+"").val().trim();
    }else if(type == 2){
        //select选择器
        updateval = $("#"+updateid+" option:selected").attr("value"); //获取选中的项
    }

    var layLoad=layer.load(2);
    $.post('/farmbusinesinfo/updatefarminfo', {
        "business_encryptId": current_business_encryptId,
        "farm_encryptId": current_farm_encryptId,
        "updatefiled":updatefiled,
        "updateval":updateval
    }, function (value) {
        layer.close(layLoad);
        if (value.status == 0 && value.msg == "ok") {

            layer.msg("修改成功！", {icon: 1,time:2000});

        } else {
            if (value.msg == null || value.msg == "") {
                layer.alert("接口出现错误！", {icon: 2})
            } else {
                layer.alert(value.msg, {icon: 2})
            }
        }
    })
}

//基本信息--立即提交
function savecalldetail(updatefiled) {

    var bussines_intr = layedit.getContent(editIndex);

    var layLoad=layer.load(2);
    $.post('/farmbusinesinfo/updatefarminfo', {
        "business_encryptId": current_business_encryptId,
        "farm_encryptId": current_farm_encryptId,
        "updatefiled":updatefiled,
        "updateval":bussines_intr
    }, function (value) {
        layer.close(layLoad);
        if (value.status == 0 && value.msg == "ok") {

            layer.msg("修改成功！", {icon: 1,time:2000});

        } else {
            if (value.msg == null || value.msg == "") {
                layer.alert("接口出现错误！", {icon: 2})
            } else {
                layer.alert(value.msg, {icon: 2})
            }
        }
    })
}


/*************************************---农家图集信息---******************************/
var layuiupload = null;
$(function () {

    //农家乐图片上传
    //文件上传
    layui.use('upload', function () {
        var upload = layui.upload;
        layuiupload = upload;
        var ii = null;
        //执行实例
    });
})


//动态绑定上传事件
function picupload(id, pic) {
    var ii = null;
    layuiupload.render({
        elem: id //绑定元素
        , url: '/xw/imgfile' //上传接口 (调用原本可以上传的url，并没有将数据存入数据库中)
        , accept: 'file'
        , before: function (obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
            ii = layer.load(2); //上传loading
        }
        , done: function (res) {
            // alert(res + "动态");
            var item = $(this.item);
            var itemurl = item.attr("id");
            layer.close(ii);
            //上传完毕回调
            if (res.status == 0) {
                $("."+itemurl).val(res.fileurl);
            } else {
                layer.alert("上传文件失败！", {icon: 1})
            }
        }
        , error: function () {
            //请求异常回调
            layer.close(ii);
            layer.alert("上传文件发生异常！", {icon: 1})
        }
    });
}

//数据列表
function myatlasinfo() {
    $("#my_atlasinfo_list").html("");
    //先查询
    $.post('/farmAtlas/getfarmaltlasinfowin', {'farm_encryptId': current_farm_encryptId}, function (value) {
        if (value.status == 0 && value.msg == "ok") {
            var list = value.list;
            var str = "";
            if(list.length>0){
                for(var i=0;i<list.length;i++){
                    str += "<li class='item'>";
                        str += "<div class='portfoliobox'>";
                            // str += "<span class='layui-btn layui-btn-xs demo-reload' style='float:left;line-height: 25px;' onclick=\"question_edit('"+list[i].id+"')\">编辑</span>";
                            // str += "<input class='checkbox' type='checkbox' value='"+list[i].id+"'>";
                            str += "<div class='picbox'>";
                                str += "<a href='javascript:void(0);' data-lightbox='gallery' data-title='图集"+Number(i+1)+"'>";
                                    str += "<img src='"+list[i].imgurl+"?x-oss-process=style/tuImgStyle' layer-src='"+list[i].imgurl+"'>";
                                str += "</a>";
                            str += "</div>";
                            str += "<div class='textbox'>图集"+Number(i+1)+"</div>";
                        str += "</div>";
                    str += "</li>";
                }
                $("#my_atlasinfo_list").html(str);
            }else {
                layer.msg("暂无数据！",{icon:0,time:2000});
            }
        } else {
            if(value=="" || value==null){
                layer.alert("接口出现错误！", {icon: 2});
            }else {
                layer.alert(value.msg, {icon: 2});
            }
        }
    });
}


//点击图片，进行放大
$(document).on("click", "#my_atlasinfo_list .picbox", function () {
    seePicture($(this).find("img").attr("layer-src"));
})

//图片放大
function seePicture(url) {
    var url = url.split(",");
    var photos = new Array();
    for (var i = 0; i < url.length; i++) {
        photos.push({"alt": "图片" + (1 + i), "pid": "", "src": url[i], "thumb": ""});
    }
    var json = {"title": "素材", "id": "", "start": 0, "data": photos};
    layer.photos({
        photos: json,
        area: "[auto,auto]",
        skin: "layer_photos"
        , shift: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
    });
}

//添加
function question_add() {
    var imgurlArry = new Array();
    $("#faceAndVideoBody").html("");

    //先查询
    $.post('/farmAtlas/getfarmaltlasinfowin', {'farm_encryptId': current_farm_encryptId}, function (value) {
        if (value.status == 0 && value.msg == "ok") {
            var list = value.list;
            if (list.length == 0) {
                imgurlArry = [];
                console.log("原数组没有数据："+imgurlArry.length+","+imgurlArry);
            }else {
                imgurlArry = list;
                console.log("原数组数据："+imgurlArry.length+","+imgurlArry);
            }
        } else {
            if(value=="" || value==null){
                layer.alert("接口出现错误！", {icon: 2});
            }else {
                layer.alert(value.msg, {icon: 2});
            }
        }
        ComOpenWin(1,"农家乐图集", "auto","auto", $('#newAtasinfobuildwin'), 1);
        newVideoInfo(1,imgurlArry); //追加样式
    });

}

//保存——提交请求
function addfarmatasinfoSave() {
    var imglinkArry = new Array(); //小类APP广告1,或者2
    var data={};

    var bodylength=$("#faceAndVideoBody tr").length
    for (var k=1;k<=bodylength;k++){
        var sx = ".advertising_cover"+k
        $(""+sx+" input[type='text']").each(function (i,item) {
            if(i==0){
                data["id"]=$(this).attr("value");
            }else if(i==1){
                data["business_encryptId"]=$(this).attr("value");
            }else if (i == 2){
                data["farm_encryptId"]=$(this).attr("value");
            }else if(i==3){
                data["imglink"]=$(this).val().trim();
            }
        })
        imglinkArry.push(data);//向数组中添加元素
        data={}; //重新赋值为空数组
    }

    //保存
    $.post('/farmAtlas/savefarmImgurl', {'parmJson': JSON.stringify(imglinkArry)}, function (value) {
        if (value.status == 0 && value.msg == "ok") {
            $("#faceAndVideoBody").html("");
            layer.closeAll();
            myatlasinfo();
            layer.msg("操作成功！",{icon:1,time:2000});
        } else {
            layer.closeAll();
            if(value=="" || value==null){
                layer.alert("接口出现错误！", {icon: 2});
            }else {
                layer.alert(value.msg, {icon: 2});
            }
        }
    });

}

// //修改
// function question_edit() {
//
//     ComOpenWin(1,"农家乐图集", "auto","auto", $('#updateAtasinfobuildwin'), 1);
// }


//追加APP广告样式
var editimgurlArry = [];
function newVideoInfo(state,imgurlArry) {

    var masterid = $("#app_masterid").attr("value"); //考试id
    var title = $("#masteridTitle").attr("value"); //考试名称

    console.log("追加数组："+imgurlArry.length+","+imgurlArry);
    var bodylength=$("#faceAndVideoBody tr").length+1;
    if (bodylength > 10) {
        layer.alert("图集不能大于10张!",{icon:0});
        return;
    }
    var  html = "";
    var html_addbtn = "";
    if (state == 1){
        html_addbtn = '<button class="add_shipinbtn" type="button" onclick="newVideoInfo(2,editimgurlArry)">'+
            '<i class="icon-plus"></i>'+
            '</button>';
    }else {
        html_addbtn = "";
    }
    if (imgurlArry.length == 0){ //返回的 imglink 没有数据。
        html =
            '<tr class="advertising_cover'+bodylength+'" style="height:90px;">'+
            '<td style="width: 15%;padding-top:15px;vertical-align: top;">农家乐图集'+bodylength+'：</td>'+
            '<td>'+
            '<input type="text" class="id" style="display: none" value="0"> '+
            '<input type="text" class="business_encryptId_app" style="display: none" value="'+current_business_encryptId+'"> '+
            '<input type="text" class="arm_encryptId_app" style="display: none" value="'+current_farm_encryptId+'"> '+
            '<input type="text" placeholder="" class="url url_app url1'+bodylength+'">'+ //图片地址
            '<a class="a_upload" style="cursor:pointer;" id="url1'+bodylength+'">上传'+ '</a>'+
            html_addbtn+
            '</td>'+
            '</tr>';
        $("#faceAndVideoBody").append(html);
        var id = "#url1"+bodylength;
        picupload(id);
        html = "";
    }
    for (var i=0;i<imgurlArry.length;i++){
        html=
            '<tr class="advertising_cover'+Number(bodylength+i)+'" style="height:90px;">'+
            '<td style="width: 15%;padding-top:15px;vertical-align: top;">农家乐图集'+Number(bodylength+i)+'：</td>'+
            '<td>'+
            '<input type="text" class="id" style="display: none" value="'+imgurlArry[i].id+'"> '+ //masterid:1249
            '<input type="text" class="business_encryptId_app" style="display: none" value="'+imgurlArry[i].business_encryptId+'"> '+ //masterid:1249
            '<input type="text" class="farm_encryptId_app" style="display: none" value="'+imgurlArry[i].farm_encryptId+'"> '+ //masterid:1249
            '<input type="text" placeholder="" class="url url_app url1'+Number(bodylength+i)+'" value="'+imgurlArry[i].imgurl+'">'+
            '<a class="a_upload" style="cursor:pointer;" id="url1'+Number(bodylength+i)+'">上传'+ '</a>' +
            html_addbtn+
            '</td>'+
            '</tr>';
        $("#faceAndVideoBody").append(html);
        var id = "#url1"+Number(bodylength+i);
        picupload(id);
    }

}


/*************************************---农家住宿信息---******************************/
var room_sortfild = '';
var room_sortway = '';
$(function () {
    //排序
    $("#my_room_sort").click(function(){
        room_sortfild = $(this).attr("value");
        if($(this).find("i").hasClass("icon_downs")) {
            $(this).find("i").removeClass("icon_downs");
            $(this).find("i").addClass("icon_ups");
            room_sortway = "asc";
        } else {
            $(this).find("i").removeClass("icon_ups");
            $(this).find("i").addClass("icon_downs");
            room_sortway = "desc";
        }
        //必须要，否则排序则不能调用该方法  使用该句，当点击排序，就同时点击了 第一页的按钮，自动调用分页的效果，
        ttname = "农家住宿信息";
        $("#first_button").click();
    })
})


//获取数据列表
function getbusinessRoominfo() {
    var field=$("#search_name").attr("value"); //搜索字段
    var pagesize = $("#selectPageSize1").text();
    var pageindex = $("#currentPage").text();
    var layLoad=layer.load(2);
    $("#my_room_list").html("");
    $("#my_room_list").empty();
    $.post('/farmroom/getfarmroomlist', {
        "pagesize": pagesize,
        "pageindex": pageindex,
        "starttime": "",
        "endtime": "",
        "searchkey": "",
        "searchval": "",
        "sortfild": room_sortfild,
        "sortway": room_sortway,
        "farm_encryptId": current_farm_encryptId
    }, function (value) {
        layer.close(layLoad);
        if(value.status==0 && value.msg == "ok"){
            var list=value.list;
            var pagecount=value.pagecount;
            var recordcount=value.recordcount;
            $("#totalSize").html(recordcount);
            $("#totalPage").html(pagecount);
            if(list.length==0){
                $("#my_room_list").prepend("<tr class=\"iframe_tr iframe_bg\"><td colspan=\"7\" style=\"width:1126px;text-align:center;\">暂无数据</td></tr>");
            }else{
                var htm="";
                for(var i=0;i<list.length;i++){
                    htm+="<tr>";
                    htm+="<td><input type=\"checkbox\" name="+list[i].room_id+" data='"+list[i].farm_encryptId+"' class=\"checkbox\"></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].room_type==null?"":list[i].room_type)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].room_desc == null ? "" :list[i].room_desc)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].price == null ? "" :list[i].price)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].number == null ? "" :list[i].number+"晚")+"</span></td>";
                    htm+="<td><span class='show_tips'>"+list[i].createtime+"</span></td>";

                    htm+="<td class='td-manage'>";
                    htm += "<a href=\"javascript:void(0)\" onclick=\"question_roomedit('"+list[i].room_id+"','"+list[i].room_type+"','"+list[i].room_desc+"','"+list[i].price+"','"+list[i].number+"')\">修改</a></div>";
                    htm += "<a href=\"javascript:void(0)\" onclick=\"question_roomdel('"+list[i].room_id+"')\">删除</a></div>";
                    htm += "</td>";

                    htm+="</tr>";
                }
                $("#my_room_list").html(htm);

            }
        }else{
            if(value.msg==null||value.msg==""){
                layer.alert("接口出现错误！", {icon: 2})
            }else{
                layer.alert(value.msg, {icon: 2})
            }
        }
    })
}

//添加
function question_roomadd() {
    $("#add_room_id").attr("value","0");
    $("#roomType").val("");
    $("#remarks").val("");
    $("#roomprice").val("");
    $("#roomnum").val("");
    ComOpenWin(1,"新建", "auto","auto", $('#newroombuildwin'), 1);
}

//修改
function question_roomedit(room_id,room_type,room_desc,price,number){
    $("#add_room_id").attr("value",room_id);
    $("#roomType").val(room_type);
    $("#remarks").val(room_desc);
    $("#roomprice").val(price);
    $("#roomnum").val(number);
    ComOpenWin(1,"修改", "auto","auto", $('#newroombuildwin'), 1);
}

//保存，提交请求
function addfarmroomSave() {
    var room_id = $("#add_room_id").attr("value");
    var roomType = $("#roomType").val().trim();
    var remarks = $("#remarks").val().trim();
    var roomprice = $("#roomprice").val().trim();
    var roomnum = $("#roomnum").val().trim();
    if(roomType == "" || roomType == null){
        layer.alert("套餐类型不能为空！",{icon:2,time:2000});
    }else if(roomprice == "" || roomprice == null){
        layer.alert("住宿单价不能为空！",{icon:2,time:2000});
    }else if(roomnum == "" || roomnum == null){
        layer.alert("晚数不能为空！",{icon:2,time:2000});
    }else {
        if($(".layui-layer-title").text() == "新建"){

        }
        var ii = layer.load(2);
        $.post('/farmroom/updatefarmroom', {
            "room_id": room_id,
            "roomType": roomType,
            "remarks": remarks,
            "roomprice": roomprice,
            "roomnum": roomnum,
            "farm_encryptId": current_farm_encryptId,
            "business_encryptId":current_business_encryptId
        }, function (data) {
            layer.close(ii);
            if (data.status == 0 && data.msg == 'ok') {
                layer.msg("操作成功！",{time:2000,icon:1});
                ttname = "农家住宿信息";
                $("#first_button").click();
                mclose();
            } else {
                if(data.msg==null||data.msg==""){
                    layer.alert("接口出现错误！", {icon: 2})
                }else{
                    layer.alert(data.msg, {icon: 2})
                }
            }
        })
    }
}

//全选批量删除
function rootm_delAll() {
    var tidsArry = new Array();
    $('#my_room_list input[class="checkbox"]:checked').each(function(){
        tidsArry.push($(this).attr("name"));//向数组中添加元素
    });
    if (tidsArry.length == 0){
        layer.alert("请至少选择一个要删除内容！",{icon:0});
    }else {
        layer.confirm('确认要删除吗？', function(index) {
            var ii = layer.load(2);
            $.post('/farmroom/delfarmroom', {"room_id": tidsArry.join(",")}, function (data) {
                layer.close(ii);
                if (data.status == 0 && data.msg == 'ok') {
                    layer.msg("操作成功！",{time:2000,icon:1});
                    ttname = "农家住宿信息";
                    $("#first_button").click();
                    mclose();
                } else {
                    if(data.msg==null||data.msg==""){
                        layer.alert("接口出现错误！", {icon: 2})
                    }else{
                        layer.alert(data.msg, {icon: 2})
                    }
                }
            })
        });
    }
}

//单个删除
function question_roomdel(room_id) {
    if(room_id != ""){
        layer.confirm('确认要删除吗？', function(index) {
            var ii = layer.load(2);
            $.post('/farmroom/delfarmroom', {"room_id": room_id}, function (data) {
                layer.close(ii);
                if (data.status == 0 && data.msg == 'ok') {
                    layer.msg("操作成功！",{time:2000,icon:1});
                    ttname = "农家住宿信息";
                    $("#first_button").click();
                    mclose();
                } else {
                    if(data.msg==null||data.msg==""){
                        layer.alert("接口出现错误！", {icon: 2})
                    }else{
                        layer.alert(data.msg, {icon: 2})
                    }
                }
            })
        });
    }else {
        layer.alert("room_id不能为空！",{icon:2,time:2000});
    }
}


/*************************************---农家美食信息---******************************/
var food_sortfild = '';
var food_sortway = '';
$(function () {
    //排序
    $(".food_list_sort_tab").click(function(){
        food_sortfild = $(this).attr("value");
        if($(this).find("i").hasClass("icon_downs")) {
            $(this).find("i").removeClass("icon_downs");
            $(this).find("i").addClass("icon_ups");
            food_sortway = "asc";
        } else {
            $(this).find("i").removeClass("icon_ups");
            $(this).find("i").addClass("icon_downs");
            food_sortway = "desc";
        }
        //必须要，否则排序则不能调用该方法  使用该句，当点击排序，就同时点击了 第一页的按钮，自动调用分页的效果，
        ttname = "农家美食信息";
        $("#first_button").click();
    })
})


//获取数据列表
function getbusinessFoodinfo() {
    var field=$("#search_name").attr("value"); //搜索字段
    var pagesize = $("#selectPageSize1").text();
    var pageindex = $("#currentPage").text();
    var layLoad=layer.load(2);
    $("#my_food_list").html("");
    $("#my_food_list").empty();
    $.post('/farmfood/getfarmfoodlist', {
        "pagesize": pagesize,
        "pageindex": pageindex,
        "starttime": "",
        "endtime": "",
        "searchkey": "",
        "searchval": "",
        "sortfild": food_sortfild,
        "sortway": food_sortway,
        "farm_encryptId": current_farm_encryptId
    }, function (value) {
        layer.close(layLoad);
        if(value.status==0 && value.msg == "ok"){
            var list=value.list;
            var pagecount=value.pagecount;
            var recordcount=value.recordcount;
            $("#totalSize").html(recordcount);
            $("#totalPage").html(pagecount);
            if(list.length==0){
                $("#my_food_list").prepend("<tr class=\"iframe_tr iframe_bg\"><td colspan=\"7\" style=\"width:1126px;text-align:center;\">暂无数据</td></tr>");
            }else{
                var htm="";
                for(var i=0;i<list.length;i++){
                    htm+="<tr>";
                    htm+="<td><input type=\"checkbox\" name="+list[i].food_id+" data='"+list[i].farm_encryptId+"' class=\"checkbox\"></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].food_type==null?"":list[i].food_type)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].food_desc == null ? "" :list[i].food_desc)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].food_price == null ? "" :list[i].food_price)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].food_number == null ? "" :list[i].food_number+"顿")+"</span></td>";
                    htm+="<td><span class='show_tips'>"+list[i].createtime+"</span></td>";

                    htm+="<td class='td-manage'>";
                    htm += "<a href=\"javascript:void(0)\" onclick=\"question_foodedit('"+list[i].food_id+"','"+list[i].food_type+"','"+list[i].food_desc+"','"+list[i].food_price+"','"+list[i].food_number+"')\">修改</a></div>";
                    htm += "<a href=\"javascript:void(0)\" onclick=\"question_fooddel('"+list[i].food_id+"')\">删除</a></div>";
                    htm += "</td>";

                    htm+="</tr>";
                }
                $("#my_food_list").html(htm);

            }
        }else{
            if(value.msg==null||value.msg==""){
                layer.alert("接口出现错误！", {icon: 2})
            }else{
                layer.alert(value.msg, {icon: 2})
            }
        }
    })
}


//添加
function question_foondadd() {
    $("#add_food_id").attr("value","0");
    $("#foodType").val("");
    $("#fondremarks").val("");
    $("#fondprice").val("");
    $("#fondnum").val("");
    ComOpenWin(1,"新建", "auto","auto", $('#newfoodbuildwin'), 1);
}

//修改
function question_foodedit(food_id,food_type,food_desc,food_price,food_number){
    $("#add_food_id").attr("value",food_id);
    $("#foodType").val(food_type);
    $("#fondremarks").val(food_desc);
    $("#fondprice").val(food_price);
    $("#fondnum").val(food_number);
    ComOpenWin(1,"修改", "auto","auto", $('#newfoodbuildwin'), 1);
}


//保存-提交请求
function addfarmfondSave() {
    var food_id = $("#add_food_id").attr("value");
    var foodType = $("#foodType").val().trim();
    var fondremarks = $("#fondremarks").val().trim();
    var fondprice = $("#fondprice").val().trim();
    var fondnum = $("#fondnum").val().trim();
    if(foodType == "" || foodType == null){
        layer.alert("套餐类型不能为空！",{icon:2,time:2000});
    }else if(fondprice == "" || fondprice == null){
        layer.alert("住宿单价不能为空！",{icon:2,time:2000});
    }else if(fondnum == "" || fondnum == null){
        layer.alert("数量不能为空！",{icon:2,time:2000});
    }else {
        var ii = layer.load(2);
        $.post('/farmfood/updatefarmfood', {
            "food_id": food_id,
            "foodType": foodType,
            "foodremarks": fondremarks,
            "foodprice": fondprice,
            "foodnum": fondnum,
            "farm_encryptId": current_farm_encryptId,
            "business_encryptId":current_business_encryptId
        }, function (data) {
            layer.close(ii);
            if (data.status == 0 && data.msg == 'ok') {
                layer.msg("操作成功！",{time:2000,icon:1});
                ttname = "农家美食信息";
                $("#first_button").click();
                mclose();
            } else {
                if(data.msg==null||data.msg==""){
                    layer.alert("接口出现错误！", {icon: 2})
                }else{
                    layer.alert(data.msg, {icon: 2})
                }
            }
        })
    }
}

//全选批量删除
function fooddelAll() {
    var tidsArry = new Array();
    $('#my_food_list input[class="checkbox"]:checked').each(function(){
        tidsArry.push($(this).attr("name"));//向数组中添加元素
    });
    if (tidsArry.length == 0){
        layer.alert("请至少选择一个要删除内容！",{icon:0});
    }else {
        layer.confirm('确认要删除吗？', function(index) {
            var ii = layer.load(2);
            $.post('/farmfood/delfarmfood', {"food_id": tidsArry.join(",")}, function (data) {
                layer.close(ii);
                if (data.status == 0 && data.msg == 'ok') {
                    layer.msg("操作成功！",{time:2000,icon:1});
                    ttname = "农家美食信息";
                    $("#first_button").click();
                    mclose();
                } else {
                    if(data.msg==null||data.msg==""){
                        layer.alert("接口出现错误！", {icon: 2})
                    }else{
                        layer.alert(data.msg, {icon: 2})
                    }
                }
            })
        });
    }
}

//单个删除
function question_fooddel(food_id) {
    if(food_id != ""){
        layer.confirm('确认要删除吗？', function(index) {
            var ii = layer.load(2);
            $.post('/farmfood/delfarmfood', {"food_id": food_id}, function (data) {
                layer.close(ii);
                if (data.status == 0 && data.msg == 'ok') {
                    layer.msg("操作成功！",{time:2000,icon:1});
                    ttname = "农家美食信息";
                    $("#first_button").click();
                    mclose();
                } else {
                    if(data.msg==null||data.msg==""){
                        layer.alert("接口出现错误！", {icon: 2})
                    }else{
                        layer.alert(data.msg, {icon: 2})
                    }
                }
            })
        });
    }else {
        layer.alert("food_id不能为空！",{icon:2,time:2000});
    }
}



/*************************************---农家评论信息---******************************/
var discus_sortfild = '';
var discus_sortway = '';
$(function () {
    //排序
    $(".discus_list_sort_tab").click(function(){
        discus_sortfild = $(this).attr("value");
        if($(this).find("i").hasClass("icon_downs")) {
            $(this).find("i").removeClass("icon_downs");
            $(this).find("i").addClass("icon_ups");
            discus_sortway = "asc";
        } else {
            $(this).find("i").removeClass("icon_ups");
            $(this).find("i").addClass("icon_downs");
            discus_sortway = "desc";
        }
        //必须要，否则排序则不能调用该方法  使用该句，当点击排序，就同时点击了 第一页的按钮，自动调用分页的效果，
        ttname = "农家评论信息";
        $("#first_button").click();
    })


    //评价图片显示
    $(document).on("click", ".show_img",function(){
        var allvalue = $(this).attr("src").split(",");
        var str = "";
        for (var i = 0; i < allvalue.length; i++) {
            if (str == "") {
                str = allvalue[i];
            } else {
                str += "," + allvalue[i];
            }
        }
        var url = str.split(",");
        var prompt = '<div class="swiper-container">';
        prompt += "<div class='swiper-wrapper jilu_swiper'>";
        for (var i = 0; i < url.length; i++) {
            prompt += "<div class=\"swiper-slide\"><img style='max-width:480px;max-height:300px;' onclick='enlargeCoatchAttachment(\"" + url + "\",\"" + url[i] + "\")' src='" + url[i] + "'></div>";
        }
        prompt += "</div>";
        if (url.length > 1) {
            /*导航按钮*/
            prompt += "<div class=\"swiper-button-prev prev_swiper\"></div><div class=\"swiper-button-next next_swiper\"></div>";
        }
        prompt += "</div>";
        /*分页器*/
        prompt += "<div class=\"swiper-pagination\"></div>";

        var cancel = "<div class=\"linepopup_div\"></div>";
            cancel += "<div class=\"d_btn\">";
            cancel += "<div class=\"linepopup_button\">";
            cancel += "<a href=\"javascript:mclose()\" class=\"sure_btn1\">取消</a>";
            cancel += "</div>";
            cancel += "</div>";


        var confirm = "";
        var html = "<div class='linepopup1'>" + prompt + "</div>" + cancel
            + confirm;
        ComOpenWin(1, "图片", "auto", 'auto', html, 1);

        var mySwiper = new Swiper('.swiper-container', {
            pagination: {
                el: '.swiper-pagination',
                type: 'fraction'
            },
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev'
            }
        })
    });

})

//图片全屏显示
function enlargeCoatchAttachment(url, currentURL) {
    var url = url.split(",");
    var photos = new Array();
    for (var i = 0; i < url.length; i++) {
        photos.push({"alt": "图片" + (1 + i), "pid": "", "src": url[i], "thumb": ""});
    }
    var json = {"title": "附件图片", "id": "", "start": url.indexOf(currentURL), "data": photos};
    layer.photos({
        photos: json
        , anim: 5, //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
        maxHeight: "80%",
        maxWidth: "80%",
        full: true
    });
}

//获取数据列表
function getbusinessDiscussinfo() {
    var field=$("#search_name").attr("value"); //搜索字段
    var pagesize = $("#selectPageSize1").text();
    var pageindex = $("#currentPage").text();
    var layLoad=layer.load(2);
    $("#my_discuss_list").empty();
    $.post('/farmdiscuss/getfarmdiscusslist', {
        "pagesize": pagesize,
        "pageindex": pageindex,
        "starttime": "",
        "endtime": "",
        "searchkey": "",
        "searchval": "",
        "sortfild": discus_sortfild,
        "sortway": discus_sortway,
        "farm_encryptId": current_farm_encryptId,
        "user_encryptId":""
    }, function (value) {
        layer.close(layLoad);
        if(value.status==0 && value.msg == "ok"){
            var list=value.list;
            var pagecount=value.pagecount;
            var recordcount=value.recordcount;
            $("#totalSize").html(recordcount);
            $("#totalPage").html(pagecount);
            if(list.length==0){
                $("#my_discuss_list").prepend("<tr class=\"iframe_tr iframe_bg\"><td colspan=\"8\" style=\"width:1126px;text-align:center;\">暂无数据</td></tr>");
            }else{
                var htm="";
                for(var i=0;i<list.length;i++){
                    htm+="<tr>";
                    htm+="<td><span class='show_tips'>"+(list[i].farmTypeName==null?"":list[i].farmTypeName)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].CompanyName == null ? "" :list[i].CompanyName)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].username == null ? "" :list[i].username)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].score == null ? "" :list[i].score+"分")+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].context == null ? "" :list[i].context)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].impression == null ? "" :list[i].impression)+"</span></td>";

                    if(list[i].discus_img != "" && list[i].discus_img != null){
                        htm += "<td><a href='javascript:void(0)' class='show_img' src='" + list[i].discus_img + "'>查看</a></td>";
                    }else {
                        htm += "<td></td>";
                    }
                    htm+="<td><span class='show_tips'>"+list[i].createtime+"</span></td>";
                    htm+="</tr>";
                }
                $("#my_discuss_list").html(htm);

            }
        }else{
            if(value.msg==null||value.msg==""){
                layer.alert("接口出现错误！", {icon: 2})
            }else{
                layer.alert(value.msg, {icon: 2})
            }
        }
    })
}



/*************************************---农家收藏信息---******************************/
var collect_sortfild = '';
var collect_sortway = '';
$(function () {
    //排序
    $(".collect_list_sort_tab").click(function(){
        collect_sortfild = $(this).attr("value");
        if($(this).find("i").hasClass("icon_downs")) {
            $(this).find("i").removeClass("icon_downs");
            $(this).find("i").addClass("icon_ups");
            collect_sortway = "asc";
        } else {
            $(this).find("i").removeClass("icon_ups");
            $(this).find("i").addClass("icon_downs");
            collect_sortway = "desc";
        }
        //必须要，否则排序则不能调用该方法  使用该句，当点击排序，就同时点击了 第一页的按钮，自动调用分页的效果，
        ttname = "农家收藏信息";
        $("#first_button").click();
    })

})

//获取数据列表
function getbusinessCollectinfo() {
    var field=$("#search_name").attr("value"); //搜索字段
    var pagesize = $("#selectPageSize1").text();
    var pageindex = $("#currentPage").text();
    var layLoad=layer.load(2);
    $("#my_collect_list").html("");
    $("#my_collect_list").empty();
    $.post('/farmCollect/getfarmcollectlist', {
        "pagesize": pagesize,
        "pageindex": pageindex,
        "starttime": "",
        "endtime": "",
        "searchkey": "",
        "searchval": "",
        "sortfild": collect_sortfild,
        "sortway": collect_sortway,
        "farm_encryptId": current_farm_encryptId,
        "user_encryptId":"",
        "shoptype":"" //店铺类型
    }, function (value) {
        layer.close(layLoad);
        if(value.status==0 && value.msg == "ok"){
            var list=value.list;
            var pagecount=value.pagecount;
            var recordcount=value.recordcount;
            $("#totalSize").html(recordcount);
            $("#totalPage").html(pagecount);
            if(list.length==0){
                $("#my_collect_list").prepend("<tr class=\"iframe_tr iframe_bg\"><td colspan=\"4\" style=\"width:1126px;text-align:center;\">暂无数据</td></tr>");
            }else{
                var htm="";
                for(var i=0;i<list.length;i++){
                    htm+="<tr>";
                    htm+="<td><span class='show_tips'>"+(list[i].farmTypeName==null?"":list[i].farmTypeName)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].CompanyName == null ? "" :list[i].CompanyName)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].username == null ? "" :list[i].username)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+list[i].createtime+"</span></td>";
                    htm+="</tr>";
                }
                $("#my_collect_list").html(htm);

            }
        }else{
            if(value.msg==null||value.msg==""){
                layer.alert("接口出现错误！", {icon: 2})
            }else{
                layer.alert(value.msg, {icon: 2})
            }
        }
    })
}


/*************************************---农家定制游信息---******************************/
var pick_sortfild = '';
var pick_sortway = '';
$(function () {
    //排序
    $(".pick_list_sort_tab").click(function(){
        pick_sortfild = $(this).attr("value");
        if($(this).find("i").hasClass("icon_downs")) {
            $(this).find("i").removeClass("icon_downs");
            $(this).find("i").addClass("icon_ups");
            pick_sortway = "asc";
        } else {
            $(this).find("i").removeClass("icon_ups");
            $(this).find("i").addClass("icon_downs");
            pick_sortway = "desc";
        }
        //必须要，否则排序则不能调用该方法  使用该句，当点击排序，就同时点击了 第一页的按钮，自动调用分页的效果，
        ttname = "农家定制信息";
        $("#first_button").click();
    })

    //下拉框
    $(document).on('click', ".my_select_ul li", function () {
        $(this).parent().siblings("div").find("span").html($(this).text());
        $(this).parent().siblings("div").find("span").attr("value", $(this).attr("value"));
        if ($(this).parent().siblings("div").find("span").hasClass("type_select")) {
            if ($(this).text() == "全部") {
                $(".type_select").text("挑选类型");
            }
        } else if ($(this).parent().siblings("div").find("span").hasClass("category_select")) {
            if ($(this).text() == "全部") {
                $(".category_select").text("定制类别");
            }
        } else if ($(this).parent().siblings("div").find("span").hasClass("datasource_select")) {
            if ($(this).text() == "全部") {
                $(".datasource_select").text("数据来源");
            }
        }else if ($(this).parent().siblings("div").find("span").hasClass("applicant_select")) {
            if ($(this).text() == "全部") {
                $(".applicant_select").text("申请人");
            }
        }
        //获取数据
        ttname = "农家定制信息";
        $("#first_button").click();
    })

})
//获取数据列表
function getbusinessCustominfo() {
    var pagesize = $("#selectPageSize1").text();
    var pageindex = $("#currentPage").text();
    var type = $("#type_select_name").attr("value");//挑选类型
    var category = $("#category_select_name").attr("value");//定制类别
    var datasource = $("#datasource_select_name").attr("value");//数据来源
    var applicant = $("#applicant_select_name").attr("value");//申请人
    var layLoad=layer.load(2);
    $("#my_pick_list").empty();
    $.post('/custom/getcustolist', {
        "pagesize": pagesize,
        "pageindex": pageindex,
        "starttime": starttime,
        "endtime": endtime,
        "searchval": "",
        "searchkey": "",
        "sortfild": pick_sortfild,
        "sortway": pick_sortway,
        "type": type,
        "category": category,
        "datasource": datasource,
        "applicant": "",
        "user_encryptId":current_farm_encryptId
    }, function (value) {
        layer.close(layLoad);
        if(value.status==0 && value.msg == "ok"){
            var list=value.list;
            var applylist = value.applylist;
            var pagecount=value.pagecount;
            var recordcount=value.recordcount;
            $("#totalSize").html(recordcount);
            $("#totalPage").html(pagecount);


            if(list.length==0){
                $("#my_pick_list").prepend("<tr class=\"iframe_tr iframe_bg\"><td colspan=\"13\" style=\"width:1126px;text-align:center;\">暂无数据</td></tr>");
            }else{
                var htm="";
                for(var i=0;i<list.length;i++){
                    htm+="<tr>";
                    htm+="<td><span class='show_tips'>"+(list[i].type==null?"":gettypeName(list[i].type))+"</span></td>";
                    // htm+="<td><span class='show_tips'>"+(list[i].applicatName == null ? "" :list[i].applicatName)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].user_name == null ? "" :list[i].user_name)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].user_realName == null ? "" :list[i].user_realName)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].tel == null ? "" :list[i].tel)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].category == null ? "" :getCategoryName(list[i].category))+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].dataSources == null ? "" :getdataSources(list[i].dataSources))+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].CompanyName == null ? "" :list[i].CompanyName)+"</span></td>";
                    htm+="<td><span class='show_tips'>"+(list[i].createtime == null ? "" :list[i].createtime)+"</span></td>";

                    htm +="<td class='td-manage'>";
                    htm += "<a href=\"javascript:void(0)\" onclick=\"question_Customdetails('"+list[i].user_tel+"','"+list[i].user_id+"','"+list[i].cust_encryptId+"','"+list[i].user_encryptId+"')\">详情</a></div>";
                    htm += "<a href=\"javascript:void(0)\" onclick=\"question_Customdel('"+list[i].cust_encryptId+"')\">删除</a></div>";
                    htm += "</td>";

                    htm+="</tr>";
                }
                $("#my_pick_list").html(htm);

            }
        }else{
            if(value.msg==null||value.msg==""){
                layer.alert("接口出现错误！", {icon: 2})
            }else{
                layer.alert(value.msg, {icon: 2})
            }
        }
    })
}

//挑选类型
function gettypeName(type) {
    if (type != ""){
        if(type == "1"){
            return "挑选农家"
        }else if(type == "2"){
            return "挑选景区"
        }
        return "";
    }
    return "";
}
//定制类型
function getCategoryName(category) {
    if (category != ""){
        if(category == "1"){
            return "私人定制"
        }else if(category == "2"){
            return "团队定制"
        }
        return "";
    }
    return "";
}
//数据来源
function getdataSources(dataSources) {
    if (dataSources != ""){
        if(dataSources == "0"){
            return "管理系统"
        }else if(dataSources == "1"){
            return "前端官网"
        }
        return "";
    }
    return "";
}

//点击详情 - 跳转商家详情信息页面（应判断用户提交的是挑选农家，还旅游景区）
function question_Customdetails(user_tel,user_id,cust_encryptId,user_encryptId){
    setcookie("tel",user_tel,1,"/");//注册时，用户填写的电话号码
    setcookie("user_id",user_id,1,"/"); //用户id
    setcookie("user_encryptid",user_encryptId,1,"/"); //用户加密id
    setcookie("cust_encryptid",cust_encryptId,1,"/"); //定制游加密id
    var size = "pick-farm/pick_info_new.html".length;
    window.parent.addTab_father("定制详情", "pick-farm/pick_info_new.html", size);
}

//删除
function question_Customdel(id) {
    layer.confirm('确认要删除吗？', function(index) {
        var ii = layer.load(2);
        $.post('/custom/delcustom', {"custEncryptid": id}, function (data) {
            layer.close(ii);
            if (data.status == 0 && data.msg == 'ok') {
                layer.msg("操作成功！",{time:2000,icon:1});
                ttname = "农家定制信息";
                $("#first_button").click();
            } else {
                if(data.msg==null||data.msg==""){
                    layer.alert("接口出现错误！", {icon: 2})
                }else{
                    layer.alert(data.msg, {icon: 2})
                }
            }
        })
    });
}